package model;

import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * Author: Kostika Gorica
 * User: kostika
 * Date: 12/28/12
 * Time: 9:42 AM
 */
public class Person {
    private int id;
    private String emri;
    private String mbiemri;
    private String atesia;
    private String amesia;
    private String mbiemriMartesor;
    private int mbiemriPerdorur;
    private Date ditelindja;
    private char seksi;
    private String statusiCivil;
    private int vendlindja;
    private int vendbanimi;
    private int gjimnazi;
    private String shtetesia;
    private String celular;
    private String telefon;
    private String telefonReference;
    private String email;
    private String emailUniversitar;
    private String gjuheAmtare;
    private String besimiFetar;
    private String pasaporta;
    private String idKarta;
    private String nrPersonal;
    private String status;
    private int portalId;

    public Person() {
        this(0,"","","","","", 1,null,' ',"",0,0,0,"","","","","","","","","","","","",0);
    }

    public Person(int id, String emri, String mbiemri, String atesia, String amesia, String mbiemriMartesor, int mbiemriPerdorur, Date ditelindja, char seksi, String statusiCivil, int vendlindja, int vendbanimi, int gjimnazi, String shtetesia, String celular, String telefon, String telefonReference, String email, String emailUniversitar, String gjuheAmtare, String besimiFetar, String pasaporta, String idKarta, String nrPersonal, String status, int portalId) {
        this.setId(id);
        this.setEmri(emri);
        this.setMbiemri(mbiemri);
        this.setAtesia(atesia);
        this.setAmesia(amesia);
        this.setMbiemriMartesor(mbiemriMartesor);
        this.setMbiemriPerdorur(mbiemriPerdorur);
        this.setDitelindja(ditelindja);
        this.setSeksi(seksi);
        this.setStatusiCivil(statusiCivil);
        this.setVendlindja(vendlindja);
        this.setVendbanimi(vendbanimi);
        this.setGjimnazi(gjimnazi);
        this.setShtetesia(shtetesia);
        this.setCelular(celular);
        this.setTelefon(telefon);
        this.setTelefonReference(telefonReference);
        this.setEmail(email);
        this.setEmailUniversitar(emailUniversitar);
        this.setGjuheAmtare(gjuheAmtare);
        this.setBesimiFetar(besimiFetar);
        this.setPasaporta(pasaporta);
        this.setIdKarta(idKarta);
        this.setNrPersonal(nrPersonal);
        this.setStatus(status);
        this.setPortalId(portalId);
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getEmri() {
        return emri;
    }

    public void setEmri(String emri) {
        this.emri = emri.trim();
    }

    public String getMbiemri() {
        return mbiemri;
    }

    public void setMbiemri(String mbiemri) {
        this.mbiemri = mbiemri.trim();
    }

    public String getAtesia() {
        return atesia;
    }

    public void setAtesia(String atesia) {
        this.atesia = atesia.trim();
    }

    public String getAmesia() {
        return amesia;
    }

    public void setAmesia(String amesia) {
        this.amesia = amesia.trim();
    }

    public String getMbiemriMartesor() {
        return mbiemriMartesor;
    }

    public void setMbiemriMartesor(String mbiemriMartesor) {
        this.mbiemriMartesor = mbiemriMartesor.trim();
    }

    public int getMbiemriPerdorur() {
        return mbiemriPerdorur;
    }

    public void setMbiemriPerdorur(int mbiemriPerdorur) {
        this.mbiemriPerdorur = (mbiemriPerdorur==2?mbiemriPerdorur:1);
    }

    public Date getDitelindja() {
        return ditelindja;
    }

    public void setDitelindja(Date ditelindja) {
        this.ditelindja = ditelindja;
    }

    public char getSeksi() {
        return seksi;
    }

    public void setSeksi(char seksi) {
        if (seksi=='M' || seksi=='F'){
            this.seksi = seksi;
        } else {
            this.seksi='_';
        }
    }

    public String getStatusiCivil() {
        return statusiCivil;
    }

    public void setStatusiCivil(String statusiCivil) {
        this.statusiCivil = statusiCivil.trim();
    }

    public int getVendlindja() {
        return vendlindja;
    }

    public void setVendlindja(int vendlindja) {
        this.vendlindja = vendlindja;
    }

    public int getVendbanimi() {
        return vendbanimi;
    }

    public void setVendbanimi(int vendbanimi) {
        this.vendbanimi = vendbanimi;
    }

    public int getGjimnazi() {
        return gjimnazi;
    }

    public void setGjimnazi(int gjimnazi) {
        this.gjimnazi = gjimnazi;
    }

    public String getShtetesia() {
        return shtetesia;
    }

    public void setShtetesia(String shtetesia) {
        this.shtetesia = shtetesia.trim();
    }

    public String getCelular() {
        return celular;
    }

    public void setCelular(String celular) {
        this.celular = celular.trim();
    }

    public String getTelefon() {
        return telefon;
    }

    public void setTelefon(String telefon) {
        this.telefon = telefon.trim();
    }

    public String getTelefonReference() {
        return telefonReference;
    }

    public void setTelefonReference(String telefonReference) {
        this.telefonReference = telefonReference.trim();
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email.trim();
    }

    public String getEmailUniversitar() {
        return emailUniversitar;
    }

    public void setEmailUniversitar(String emailUniversitar) {
        this.emailUniversitar = emailUniversitar.trim();
    }

    public String getGjuheAmtare() {
        return gjuheAmtare;
    }

    public void setGjuheAmtare(String gjuheAmtare) {
        this.gjuheAmtare = gjuheAmtare.trim();
    }

    public String getBesimiFetar() {
        return besimiFetar;
    }

    public void setBesimiFetar(String besimiFetar) {
        this.besimiFetar = besimiFetar.trim();
    }

    public String getPasaporta() {
        return pasaporta;
    }

    public void setPasaporta(String pasaporta) {
        this.pasaporta = pasaporta.trim();
    }

    public String getIdKarta() {
        return idKarta;
    }

    public void setIdKarta(String idKarta) {
        this.idKarta = idKarta.trim();
    }

    public String getNrPersonal() {
        return nrPersonal;
    }

    public void setNrPersonal(String nrPersonal) {
        this.nrPersonal = nrPersonal.trim();
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status.trim();
    }

    public int getPortalId() {
        return portalId;
    }

    public void setPortalId(int portalId) {
        this.portalId = portalId;
    }

    @Override
    public String toString() {
        return String.format("%-30s %-30s",emri,(mbiemriPerdorur==1?mbiemri:mbiemriMartesor));
    }

    @Override
    public boolean equals(Object obj) {
        Person tmp = null;
        try{
            tmp = (Person) obj;
        } catch (ClassCastException ex){
            System.err.printf("Tried to cast from: (%s) to (Person)\n", obj.getClass().getName());
        }
        if (tmp != null){
            if (tmp.getId()>0 && tmp.getId()==this.getId()){
                return true;
            }
            if (tmp.getIdKarta() != null && !tmp.getIdKarta().equalsIgnoreCase("") && tmp.getIdKarta().equalsIgnoreCase(this.getIdKarta())){
                return true;
            }
        }
        return false;
    }
}
